package com.example.cpop.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-10-15
 * Time: 15:36
 */
//config配置
@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Bean
    //BCrypt加密
    public BCryptPasswordEncoder getBCryptPasswordEncoder(){
        return new BCryptPasswordEncoder();
    }


    //添加拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        LoginInterceptor loginInterceptor = new LoginInterceptor();
        registry.addInterceptor(loginInterceptor).
                     addPathPatterns("/**")
                //排除所有的JS
                    .excludePathPatterns("/js/**.js")
                    //排除images下所有的元素
                    .excludePathPatterns("/images/**")
                    .excludePathPatterns("/css/**.css")
                    .excludePathPatterns("/fronts/**")
                    .excludePathPatterns("/player/**")
                    .excludePathPatterns("/login.html")
                    //排除登录接口
                    .excludePathPatterns("/user/login");

    }
}
